Printed Representation and Read Syntax
Table of Contents
- Printed Representation
- The format of the output generated by the Lisp printer, i.e., function
prin1, for that object. Each data type has a unique printed representation. - Read Syntax
- The format of the input accepted by the Lisp reader, i.e., function
read, for that object.
However, some types may not have a read syntax. They are are printed in hash notation, which consists of the characters #<, a descriptive string, and a closing >. The Lisp reader signals invalid-read-syntax whenever it encounter a hash notation.
When we evaluate an expression interactively, the Lisp interpreter first reads the textual representation of it, producing a Lisp object, and then evaluates the object.
1. Special Read Syntax
#< ... >- Hash notation. Objects that have no read syntax are presented like this.
##- The printed representation of an interned symbol whose name is an empty string.
#'- Shortcut for functions.
#:- The printed representation of an uninterned symbol whose name is
foois#:foo #N
1.1. Characters, Control-Characters
For character type (like char in other languages), ?<char> is the read syntax, for example, ?A evaluates to 65, which is A’s ASCII number.
In order to support unicode and special characters, the <char> part can be \N{name of character}, \N{U+hex number}, \Uxxxxx, etc.
This notation can be extended to represent control characters, i.e., involving CTRL, ALT, etc.